<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>支付表管理</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<script type="text/javascript">
    var basePath = '<%=path%>';
    var update = '${update}';
    var quitPrioFlag = '${quitPrioFlag}';
    var grid = null;
    $(function () {
        initGrid();//grid
        $("#searchBar").ligerForm();
        $("#searchBtn").click(function (event) {
            var form = new liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
        });
        initCondition();
    });

    function initCondition() {
    }

    function clearBtn() {
        $("#searchBar").ligerForm();
        var form = new liger.get("searchBar");
        form.setData({
            cstNm: "",
            splNm: "",
            prjNm: "",
            prjTypCd: "",
            buOrgCd: "",
            bizTypCd: "",
            lsDt: "",
            lsCntNo: "",
            timeType: "",
            strDate: "",
            endDate: "",
            prdStsCd: "",
            tagTypeCd: "",
            paySchNo: "",
            icbcFlag: "",
            isLowBiz: "",
            firstPrdStsCd: ""
        });
    }

    //初始化列表
    function initGrid() {
        var params = {};

        if (update == "0") {
            $("#transFlg").val(1);
            params = {
                transFlg: 1
            };
        }
        $("#grid").ligerGrid({
            url: basePath + '/project/prjprdpayschm/getPrjPrdPaySchMList.do',
            method: 'get',
            parms: params,
            columns: [
                {display: '合同编号', name: 'lsCntNo', minWidth: 150, align: 'left', enabledSort: true},
                {
                    display: '支付表号', name: 'paySchNo', minWidth: 200, align: 'left', enabledSort: true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = '';
                        h += '<a href="javascript:detailBtn(';
                        h += "'" + rowdata.prjPrdDtlId + "',";
                        h += "'" + rowdata.id + "',";
                        h += "'" + rowdata.prjPrdId + "',";
                        h += "'" + rowdata.prjId + "'";
                        h += ')">' + value + '</a>'
                        return h;
                    }
                },
                {display: '承租人名称', name: 'cstNm', minWidth: 80, align: 'left', enabledSort: true},
                {display: '状态', name: 'prdStsCdNm', minWidth: 80, align: 'left', enabledSort: true},
                {display: '创建时间', name: 'crtTm', minWidth: 80, align: 'left', enabledSort: true, render: renderDate},
                {display: '起租日', name: 'lsDt', minWidth: 80, align: 'left', enabledSort: true, render: renderDate},
                {display: '结清时间', name: 'stlDt', minWidth: 80, align: 'left', enabledSort: true, render: renderDate},
                {display: '拖回时间', name: 'backDt', minWidth: 80, align: 'left', enabledSort: true, render: renderDate},
                {display: '转正常时间', name: 'formDt', minWidth: 80, align: 'left', enabledSort: true, render: renderDate},
                {display: '是否低息', name: 'isLowBiz', minWidth: 80, align: 'left', enabledSort: true,
                    render:function (rowdata, rowindex, value, column) {
                        if(rowdata.isLowBiz == 1){
                            return "是";
                        }else{
                            return "否"
                        }
                    }
                },
                getOpt7Columns(),
                getOptIrrColumns(),
                {display: '是否退换车', name: 'tagTypeCd', minWidth: 80, align: 'left', enabledSort: true, render: rendertagTypeCd},
                getOpt8Columns()
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            checkbox: true,
            allowUnSelectRow: true,
            alternatingRow: true,
            rownumbers: true,
            enabledEdit: false,
            fixedCellHeight: false,
            usePagerOnLessPagesize: true,
        });
        grid = liger.get("grid");
        grid.setHeight(300);

    }

    function getOptIrrColumns() {
        var isShowStlCstIrr = $('#isShowStlCstIrr').val();
        var colIrr = null;
        if ('1' == isShowStlCstIrr) {
            colIrr = {
                display: '结清对客IRR(%)', name: 'cstStlIrr', minWidth: 100, enabledSort: true,
                render: function (rowdata, rowindex, value, column) {
                    if (rowdata.cstStlIrr) {
                        return rowdata.cstStlIrr * 100;
                    }
                },
            };
        }
        return colIrr;
    }

    function getOpt7Columns() {
        var col7 = {
            display: '申请单号', name: 'pNo', minWidth: 140,
            render: function (rowdata, rowindex, value, column) {
                var h = '';
                var prdStsCd = rowdata.prdStsCd;
                if (value && value != "null") {
                    if (prdStsCd.indexOf(ProjectConstant.CODE_PRJ_PAY_SET) == 0 || prdStsCd.indexOf(ProjectConstant.CODE_PRJ_PAY_PRE_SET) == 0) {
                        h += '<a href="javascript:commShowFlow(' + rowindex + ')">' + value + '</a>';
                    }
                }
                return h;
            },
            enabledSort: true
        };
        return col7;
    }
    function getOpt8Columns() {
        var col8 = {
            display: '操作',
            isSort: false,
            width: 300,
            align: 'center',
            isEllipsis: false,
            render: function (rowdata, rowindex, value) {
                var newTagTypeCd = rowdata.tagTypeCd;
                console.log("newTagTypeCd:"+newTagTypeCd);
                if (null != rowdata.bizFlag && rowdata.bizFlag == '2') {
                    return "";
                }
                var h = "";
                if (update != "0") {
                    h += '<a class="sq-button-hasicon" href="javascript:addRickDep(';
                    h += "'" + rowdata.id + "'";
                    h += ')"><i class="sqBtnIco_3"></i>添加风险保证金</a>'
                    var h2 = "";
                    h2 += '<a class="sq-button-hasicon" href="javascript:payDetail(';
                    h2 += "'" + rowdata.id + "'";
                    h2 += ')"><i class="sqBtnIco_2"></i>查看还款情况</a>';

                    h2 += '<a class="sq-button-hasicon" href="javascript:exportRentNoticeNew(';
                    h2 += "'" + rowdata.id + "'";
                    h2 += ')"><i class="sqBtnIco_21"></i>导出起租通知书</a>';

                    h2 += '<a class="sq-button-hasicon" href="javascript:exportFirstPayAmtNew(';
                    h2 += "'" + rowdata.id + "'";
                    h2 += ')"><i class="sqBtnIco_21"></i>导出首期款明细</a>';

                    h2 += '<a class="sq-button-hasicon" href="javascript:exportPrjPrdPaySchNew(';
                    h2 += "'" + rowdata.id + "'";
                    h2 += ')"><i class="sqBtnIco_21"></i>导出支付表</a>';
                    if (rowdata.buOrgCd == ProjectConstant.CODE_BU_ORG_CD_ZK || rowdata.buOrgCd == ProjectConstant.CODE_BU_ORG_CD_YC
                            || rowdata.buOrgCd == ProjectConstant.CODE_BU_ORG_CD_ZC || rowdata.buOrgCd == ProjectConstant.CODE_BU_ORG_CD_XNY) {
                        //发起正常结清流程
                        h2 += '<a class="sq-button-hasicon" href="javascript:applyNormalSett(';
                        h2 += "'" + rowdata.id + "',";
                        h2 += "'" + rowdata.prjId + "',";
                        h2 += "'" + rowdata.lsPd + "',";
                        h2 += "'" + rowdata.startLsPd + "',";
                        h2 += "'" + rowdata.paySchNo + "'";
                        h2 += ')"><i class="sqBtnIco_6"></i>正常结清</a>';
                        //发起提前结清流程
                        h2 += '<a class="sq-button-hasicon" href="javascript:applyPerSett(';
                        h2 += "'" + rowdata.id + "',";
                        h2 += "'" + rowdata.prjId + "',";
                        h2 += "'" + rowdata.lsPd + "',";
                        h2 += "'" + rowdata.startLsPd + "',";
                        h2 += "'" + rowdata.paySchNo + "'";
                        h2 += ')"><i class="sqBtnIco_6"></i>提前结清</a>';
                    }
                    // 轻卡
                    if (rowdata.buOrgCd == ProjectConstant.CODE_BU_ORG_CD_QK) {
                        h2 += '<a class="sq-button-hasicon" href="javascript:toApplySettle(';
                        h2 += "'" + rowindex + "'";
                        h2 += ')"><i class="sqBtnIco_35"></i>去结清</a>';
                    }
                    //乘用车 提前结清
                    if (rowdata.buOrgCd == ProjectConstant.CODE_BU_ORG_CD_CAR) {
                        //发起提前结清流程
                        h2 += '<a class="sq-button-hasicon" href="javascript:applyCarPreSett(';
                        h2 += "'" + rowdata.id + "',";
                        h2 += "'" + rowdata.prjId + "',";
                        h2 += "'" + rowdata.lsPd + "',";
                        h2 += "'" + rowdata.startLsPd + "',";
                        h2 += "'" + rowdata.paySchNo + "',";
                        h2 += "'" + rowdata.prjTypCd + "',";
                        h2 += "'" + rowdata.prdTypCd + "'";
                        h2 += ')"><i class="sqBtnIco_6"></i>提前结清</a>';

                        //发起正常结清流程
                        h2 += '<a class="sq-button-hasicon" href="javascript:applyCarNormalSett(';
                        h2 += "'" + rowdata.id + "',";
                        h2 += "'" + rowdata.prjId + "',";
                        h2 += "'" + rowdata.lsPd + "',";
                        h2 += "'" + rowdata.startLsPd + "',";
                        h2 += "'" + rowdata.paySchNo + "',";
                        h2 += "'" + rowdata.prjTypCd + "',";
                        h2 += "'" + rowdata.prdTypCd + "'";
                        h2 += ')"><i class="sqBtnIco_6"></i>正常结清</a>';
                    }
                    if (rowdata.prdStsCdNm == "已拖回") {
                        //发起追加费用
                        h2 += '<a class="sq-button-hasicon" href="javascript:additionalCharges(';
                        h2 += "'" + rowdata.id + "',";
                        h2 += "'" + rowdata.paySchNo + "'";
                        h2 += ')"><i class="sqBtnIco_6"></i>追加费用</a>';
                    }

                    var tagName = "add";
                    //退换车标签 0-否,1-退车,2-换车,3-换承租人
                    if (quitPrioFlag != "0"){
                        if(newTagTypeCd == "1" || newTagTypeCd == "2" || newTagTypeCd == "3"){
                            tagName = "reset";
                            h2 += '<a class="sq-button-hasicon" href="javascript:siteTagTypeCd(';
                            h2 += "'" + rowdata.paySchNo + "',";
                            h2 += "'" + tagName + "'";
                            h2 += ')"><i class="sqBtnIco_6"></i>重置退换车标签</a>';
                        }else{
                            h2 += '<a class="sq-button-hasicon" href="javascript:siteTagTypeCd(';
                            h2 += "'" + rowdata.paySchNo + "',";
                            h2 += "'" + tagName + "'";
                            h2 += ')"><i class="sqBtnIco_6"></i>新增退换车标签</a>';
                        }
                    }
                    if (rowdata.isLowBiz == 1){
                        <sys:funcAuth resCd="cancelLowBiz">
                        h2 += '<a class="sq-button-hasicon" href="javascript:showIsLowBiz(';
                        h2 += "'" + rowdata.prjId + "'";
                        h2 += ')"><i class="sqBtnIco_6"></i>取消低息标记</a>'
                        </sys:funcAuth>
                    }
                    //退换车标签维护
                    //if (quitPrioFlag != "0"){
                    //    h2 += '<a class="sq-button-hasicon" href="javascript:siteTagTypeCd(';
                    //   h2 += "'" + rowdata.paySchNo + "'";
                    //    h2 += ')"><i class="sqBtnIco_6"></i>退换车标签维护</a>';
                    //}

                    return h + SQ.dropLinks(h2);
                } else {
                    h += '<a class="sq-button-hasicon" href="javascript:changeLsDt(';
                    h += "'" + rowdata.id + "',";
                    h += "'" + rowdata.lsDt + "'";
                    h += ')">修改起租日</a>';
                    h += '<a class="sq-button-hasicon" href="javascript:changePayPd(';
                    h += "'" + rowdata.id + "',";
                    h += "'" + rowdata.lsPd + "'";
                    h += ')">修改提前还清期次</a>';

                  //退换车标签 0-否,1-退车,2-换车,3-换承租人
                  if (quitPrioFlag != "0"){
                      if(newTagTypeCd == "1" || newTagTypeCd == "2" || newTagTypeCd == "3"){
                          tagName = "reset";
                          h += '<a class="sq-button-hasicon" href="javascript:siteTagTypeCd(';
                          h += "'" + rowdata.paySchNo + "',";
                          h += "'" + tagName + "'";
                          h += ')"><i class="sqBtnIco_6"></i>重置退换车标签</a>';
                      }else{
                          h += '<a class="sq-button-hasicon" href="javascript:siteTagTypeCd(';
                          h += "'" + rowdata.paySchNo + "',";
                          h += "'" + tagName + "'";
                          h += ')"><i class="sqBtnIco_6"></i>新增退换车标签</a>';
                      }
                  }
                    //退换车标签维护
                    //if (quitPrioFlag != "0"){
                    //    h += '<a class="sq-button-hasicon" href="javascript:siteTagTypeCd(';
                    //    h += "'" + rowdata.paySchNo + "'";
                    //    h += ')"><i class="sqBtnIco_6"></i>退换车标签维护</a>';
                    //}

                    return h;
                }

            }
        };
        return col8;
    }

    //显示流程
    function commShowFlow(rowindex) {
        var rowdata = grid.getRow(rowindex);
        var _pInstId = rowdata.pinstId;
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: {procId: _pInstId, type: "1"},
            url: basePath + '/settlement/queryFlowData.do',
            success: function (msg) {
                if (msg.success == 1) {
                    var params = "?pInsId=" + _pInstId + "&status=" + msg.data.audStsCd + "&businessKey=" + msg.data.dataId + "&formUrl=" + msg.data.formUrl;
                    Add_navTab('tab_settle_look_flow_' + _pInstId, msg.data.pno, basePath + "/flow/flow/toFlowShowPageFowBus.do" + params);
                } else {
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value && value != '') {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }

    //转化标签类似
    function rendertagTypeCd(rowdata, index, value){
            var tagTypeCd = "否";
            if(value == "1"){
                tagTypeCd = "退车";
            }
            if(value == "2"){
                tagTypeCd = "换车";
            }
            if(value == "3"){
                tagTypeCd = "换承租人";
            }
            return tagTypeCd;
   }

    function addRickDep(id) {
        $.ligerDialog.open({
            title: '添加风险保证金信息',
            height: 300,
            width: 700,
            url: basePath + '/project/prjprdpayschm/toAddRickDepPage.do?id=' + id,
            buttons: [{
                text: "保存", onclick: onSave, type: 'ok', cls: 'l-dialog-btn-ok'
            }, {
                text: "取消", onclick: onCancel, type: 'cancel', cls: 'l-dialog-btn-no'
            }]
        });
    }

    function changeLsDt(id, lsDt) {
        if (lsDt == "null") {
            $.ligerDialog.open({
                width: 700,
                buttons: [{
                    text: "保存", type: 'ok', cls: 'l-dialog-btn-ok', onclick: function () {
                        changeSave(id);
                    }
                }, {
                    text: "取消", type: 'cancel', cls: 'l-dialog-btn-no', onclick: function () {
                        $.ligerDialog.hide();
                    }
                }],
                title: '修改起租日',
                target: $("#changeLsDt")
            });
            var ligerForm = $("#changeLsDt_form").ligerForm({validate: true});
            var form = new liger.get("changeLsDt_form");
            form.setData({
                lsDtParam: ""
            });
        } else {
            $.ligerDialog.SQalert({content: "只能修改起租日为空的支付表!", SQ_type: "error"});
        }

    }

    function changePayPd(id, lsPd) {
        $.ligerDialog.open({
            width: 720,
            buttons: [{
                text: "保存", type: 'ok', cls: 'l-dialog-btn-ok', onclick: function () {
                    changePayPdSave(id, lsPd);
                }
            }, {
                text: "取消", type: 'cancel', cls: 'l-dialog-btn-no', onclick: function () {
                    $.ligerDialog.hide();
                }
            }],
            title: '修改提前还清期次',
            target: $("#changePayPd")
        });
        var ligerForm = $("#changePayPd_form").ligerForm({validate: true});
        var form = new liger.get("changePayPd_form");
        form.setData({
            payPdParam: ""
        });
        setPayPdOption(lsPd);
    }

    function setPayPdOption(lsPd) {
        var lspd = parseInt(lsPd);
        liger.get("payPdParam").clearContent();
        var newOptions = '<option value=""></option>';
        if (lspd > 0) {
            for (var i = 1; i < lspd + 1; i++) {
                newOptions += '<option value="' + i + '">' + i + '期</option>';
            }
        }
        $("#payPdParam").html($(newOptions));
        liger.get("payPdParam").setSelect();
    }

    function changeSave(id) {
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: {
                id: id,
                lsDt: $("#lsDtParam").val()
            },
            url: basePath + '/project/prjprdpayschm/modifyLsDt.do',
            success: function (msg) {
                if (msg.success == 1) {
                    $.ligerDialog.hide();
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                    grid.reload();
                } else {
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }

    function changePayPdSave(id, lsPdMax) {
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: {
                id: id,
                payPd: $("#payPdParam").val(),
                lsPdMax: lsPdMax
            },
            url: basePath + '/project/prjPrdPaySchD/modifyPayPd.do',
            success: function (msg) {
                if (msg.success == 1) {
                    $.ligerDialog.hide();
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                    grid.reload();
                } else {
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }

    function payDetail(id) {
        var payDetailUrl = basePath + '/project/prjprdpayschm/toPrjPrdPaySchMDetailPage.do?id=' + id;
        Add_navTab('tab_prj_quat_prps_pay' + id, '查看还款情况', payDetailUrl);
    }

    // 正常结清申请
    function applyNormalSett(id, prjId, payPd, startLsPd, paySchNo) {
        var checkUrl = "/project/prjprdpayschm/checkPrjPaySchFlag.do";
        var callback = function () {
            grid.reload();
        }
        var params = {};
        params.paySchId = id;
        params.sett = "normal";
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: params,
            url: basePath + checkUrl,
            success: function (msg) {
                if (msg.success == 1) {
                    if (msg.data == 1) {
                        Add_navTab('tab_prj_quat_prps_pre_sett' + id, '支付表正常结清信息详情', basePath + '/project/prjprdpayschm/showChooseSettlePdPage.do?paySchId=' + id + '&&prjId=' + prjId + '&&payPd=' + payPd + '&&startLsPd=' + startLsPd + '&&paySchNo=' + paySchNo, callback);
                    } else if(msg.data == 2) {
                        Add_navTab('tab_settle_financial_institution' + id, '资管正常结清选择期次', basePath + '/project/financialInst/showChooseSettlePdPage.do?settleType=1&prjId=' + prjId, callback);
                    }
                } else {
                    UIUtils.alertErrorHold1(msg.info);
                }
            }
        });
    }

    /*// 判断业务标识是否为资管
    function isFinancialInst(bizFlag) {
        if (bizFlag != '1' && bizFlag != '2') {
            return true;
        }
        return false;
    }*/
    // 选择是否低息业务
    function showIsLowBiz(prjId){
        $("#lowBizPrjId").val(prjId);
        $.ligerDialog.open({
            width: 600,
            minHeight:300,
            // top: 500,
            title: '选择是否低息业务',
            target: $("#setIsLowBiz"),
        });
    }
    // 更新是否低息标识
    function setIsLowBiz(prjId) {
        var prjId = $("#lowBizPrjId").val();
        var isLowBiz = $("#isLowBiz").val();
        if (StringUtils.isEmpty(isLowBiz)){
            top.alert("请先选择是否低息业务");
        }
        $.ajax({
            type: 'get',
            dataType: 'json',
            url:basePath + "/project/prjquatprps/setIsLowBiz.do?prjId="+prjId + "&isLowBiz=" + isLowBiz,
            success:function (result) {
                if (result.success == 1 && result.data){
                    $.ligerDialog.hide()
                    $.ligerDialog.close() ;
                    initGrid();
                }
            },
            error:function () {
                UIUtils.alertErrorHold1("更新是否低息失败");
                $.ligerDialog.hide() ;
            }
        })
    }
    // 提前结清申请
    function applyPerSett(id, prjId, payPd, startLsPd, paySchNo) {
        var checkUrl = "/project/prjprdpayschm/checkPrjPaySchFlag.do";
        var callback = function () {
            grid.reload();
        }
        var params = {};
        params.paySchId = id;
        params.sett = "pre";
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: params,
            url: basePath + checkUrl,
            success: function (msg) {
                if (msg.success == 1) {
                    if (msg.data == 1) {
                        Add_navTab('tab_prj_quat_prps_pre_sett' + id, '支付表提前结清信息详情', basePath + '/project/prjprdpayschm/showChoosePreSettlePdPage.do?paySchId=' + id + '&&prjId=' + prjId + '&&payPd=' + payPd + '&&startLsPd=' + startLsPd + '&&paySchNo=' + paySchNo, callback);
                    } else if(msg.data == 2){
                        Add_navTab('tab_settle_financial_institution' + id, '资管提前结清选择期次', basePath + '/project/financialInst/showChooseSettlePdPage.do?settleType=2&prjId=' + prjId, callback);
                    }
                } else {
                    UIUtils.alertErrorHold1(msg.info);
                }
            }
        });
    }

    // 到选择结清期次页面
    function toApplySettle(rowindex) {
        var rowdata = liger.get("grid").getRow(rowindex);
        Add_navTab('TAB_TO_APPLY_SETTLE_' + rowdata.id, '选择结清期次', basePath + '/settlement/bill/chooseSettlePd.do?id=' + rowdata.id, callback);
    }

    var onSave = function (item, Dialog) {
        //在子页面里绑定 frameElement.dialog.onOk = function () {}
        if (Dialog.onSave) Dialog.onSave();
    };

    var onCancel = function (item, Dialog) {
        //在子页面里绑定 frameElement.dialog.onOk = function () {}
        if (Dialog.onCancel) Dialog.onCancel();
    };

    function detailBtn(prjPrdDtlId, id, prjPrdId, prjId) {
        var editFlag = true;
        Add_navTab('tab_prj_quat_prps' + id, '查看支付表', basePath + '/project/prjprdpayschm/toAddPage.do?prjId=' + prjId + '&&id=' + id + '&&prjPrdDtlId=' + prjPrdDtlId + '&&prjPrdId=' + prjPrdId + '&&detailFlag=' + editFlag);
    }

    function iframeResize() {
        if (parent.mainApp) {
            parent.mainApp.parentTab.onResize();
        }
    }

    //汽车金融正常结清
    function applyCarNormalSett(id, prjId, payPd, startLsPd, paySchNo, prjTypCd, prdTypCd) {
        if (prjTypCd == 'DSFZGCP' || prjTypCd == 'DSFZGCT' || (prjTypCd == 'GHKD' && prdTypCd != '022')) {
            UIUtils.alertWarningHold1("三方资管不能发起结清流程!");
            return;
        }

        var callback = function () {
            grid.reload();
        }
        var params = {};
        params.paySchId = id;
        params.sett = "normal";
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: params,
            url: basePath + '/project/prjprdpayschm/checkPrjPaySchFlag.do',
            success: function (msg) {
                if (msg.success == 1) {
                    Add_navTab('tab_prj_quat_prps_pre_sett' + id, '支付表正常结清信息详情', basePath + '/project/prjprdpayschm/showCarNormalSettlePage.do?paySchId=' + id + '&&prjId=' + prjId + '&&payPd=' + payPd + '&&startLsPd=' + startLsPd + '&&paySchNo=' + paySchNo, callback);
                } else {
                    UIUtils.alertErrorHold1(msg.info);
                }
            }
        });
    }

    function siteTagTypeCd(paySchNo,tagName){
        Add_navTab('tab_prj_prd_pay_tag' + paySchNo, '退换车标签维护', basePath + '/project/prjprdpayschm/toSiteTagTypeCdPage.do?paySchNo=' + paySchNo+"&&tagName="+tagName);
	}

    function applyCarPreSett(id, prjId, payPd, startLsPd, paySchNo, prjTypCd, prdTypCd) {
        if (prjTypCd == 'DSFZGCP' || prjTypCd == 'DSFZGCT' || (prjTypCd == 'GHKD' && prdTypCd != '022')) {
            UIUtils.alertWarningHold1("三方资管不能发起结清流程!");
            return;
        }

        var callback = function () {
            grid.reload();
        }
        var params = {};
        params.paySchId = id;
        params.sett = "pre";
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: params,
            url: basePath + '/project/prjprdpayschm/checkPrjPaySchFlag.do',
            success: function (msg) {
                if (msg.success == 1) {
                    Add_navTab('tab_prj_quat_prps_pre_sett' + id, '支付表提前结清信息详情', basePath + '/project/prjprdpayschm/showCarPreSettlePage.do?paySchId=' + id + '&&prjId=' + prjId + '&&payPd=' + payPd + '&&startLsPd=' + startLsPd + '&&paySchNo=' + paySchNo, callback);
                } else {
                    UIUtils.alertErrorHold1(msg.info);
                }
            }
        });
    }

    function additionalCharges(id, paySchNo) {
        Add_navTab('tab_ass_sch_fee', '已拖回追加费用项', basePath + '/ass/assSchFee/toAssSchFeePage.do?paySchId=' + id + '&&paySchNo=' + paySchNo, callback);
    }

    var callback = function () {
        var form = new liger.get("searchBar");
        var data = form.getData();
        for (name in data) {
            grid.setParm(name, data[name]);
        }
        grid.reload();
    };

    /* 导出 */
    function exportPrjPrdPaySchNew(id) {
        var params = {};
        params.id = id;
        var url = basePath + '/project/prjprdpayschm/exportPrjPrdPaySchNew.do';
        var wait_dialog;
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: url,
            data: params,
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: '正在导出...', SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                    var tempwindow = window.open("_blank");
                    tempwindow.location = msg.data;
                } else {
                    $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }

    /* 导出起租提醒 */
    function exportRentNoticeNew(id) {
        var params = {};
        params.id = id;
        var url = basePath + '/project/prjprdpayschm/exportRentNoticeNew.do';
        var wait_dialog;
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: url,
            data: params,
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: '正在导出...', SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                    var tempwindow = window.open("_blank");
                    tempwindow.location = msg.data;
                } else {
                    $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }

    /* 导出首期明细 */
    function exportFirstPayAmtNew(id) {
        var params = {};
        params.id = id;
        var url = basePath + '/project/prjprdpayschm/exportFirstPayAmtNew.do';
        var wait_dialog;
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: url,
            data: params,
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: '正在导出...', SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                    var tempwindow = window.open("_blank");
                    tempwindow.location = msg.data;
                } else {
                    $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }
</script>

<body class="iframeBody">
<div class="Wrapper">
    <div>
        <div id="pageInTab" class="pageInTab">
            <div class="searchArea">
                <form id="searchBar">
                    <div class="fieldset1 clearFix">
                        <input id="transFlg" name="transFlg" style="display:none"/>
                        <div class="fieldBox col_33">
                            <div class="label">客户名称</div>
                            <div class="field">
                                <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">项目名称</div>
                            <div class="field">
                                <input name="prjNm" id="prjNm" type="text" class="ui-textbox" value="">
                            </div>
                        </div>
                        <div class="fieldBox">
                            <div class="label">项目类型</div>
                            <div class="field">
                                <select name="prjTypCd" id="prjTypCd">
                                    <option value="  " selected="selected">--请选择--</option>
                                    <c:forEach items="${projectTypeList}" var="opt">
                                        <option value="${opt.key}">${opt.value}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox">
                            <div class="label">业务类型</div>
                            <div class="field">
                                <select name="bizTypCd" id="bizTypCd">
                                    <option value="  " selected="selected">--请选择--</option>
                                    <c:forEach items="${bizTypeList}" var="opt">
                                        <option value="${opt.key}">${opt.value}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox">
                            <div class="label">所属事业部</div>
                            <div class="field">
                                <select name="buOrgCd" id="buOrgCd">
                                    <option value=" " seleted>请选择</option>
                                    <c:forEach items="${orgListList }" var="org">
                                        <c:if test="${currentBuOrgCd == org.key }">
                                            <option value="${org.key }" selected>${org.value }</option>
                                        </c:if>
                                        <c:if test="${currentBuOrgCd != org.key }">
                                            <option value="${org.key }">${org.value }</option>
                                        </c:if>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">供应商名称</div>
                            <div class="field">
                                <input name="splNm" id="splNm" type="text" class="ui-textbox" value="">
                            </div>
                        </div>

                        <div class="fieldBox col_33" isHide="yes">
                            <div class="label">起租日</div>
                            <div class="field">
                                <input name="lsDt" id="lsDt" type="text" class="ui-datepicker" value="">
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">合同编号</div>
                            <div class="field">
                                <input name="lsCntNo" id="lsCntNo" type="text" class="ui-textbox" value="">
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">是否删除</div>
                            <div class="field">
                                <select name="isDel" id="isDel">
                                    <option value="0" selected="selected">否</option>
                                    <option value="1">是</option>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox col_33" isHide="yes">
                            <div class="label">支付表状态</div>
                            <div class="field">
                                <select name="prdStsCd" id="prdStsCd">
                                    <option value="  " selected="selected">--请选择--</option>
                                    <c:forEach items="${prdStsCdList}" var="opt">
                                        <option value="${opt.key}">${opt.value}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">支付表号</div>
                            <div class="field">
                                <input name="paySchNo" id="paySchNo" type="text" class="ui-textbox" value="">
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">是否退换车业务</div>
                            <div class="field">
                                <select name="tagTypeCd" id="tagTypeCd">
                                    <option value="  " selected="selected">--请选择--</option>
                                    <c:forEach items="${tagTypeCdList}" var="opt">
                                        <option value="${opt.key}">${opt.value}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">是否工行卡贷业务</div>
                            <div class="field">
                                <select name="icbcFlag" id="icbcFlag" data-value=" ">
                                    <option value=" " seleted >请选择</option>
                                    <c:forEach items="${yesOrNoCdList }" var="kv">
                                        <option value="${kv.key }">${kv.value }</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">是否低息</div>
                            <div class="field">
                                <select name="isLowBiz" id="isLowBiz" data-value=" ">
                                    <option value=" " seleted >请选择</option>
                                    <c:forEach items="${yesOrNoCdList }" var="kv">
                                        <option value="${kv.key }">${kv.value }</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox col_33" isHide="yes">
                            <div class="label">时间</div>
                            <div class="field">
                                <select name="timeType" id="timeType">
                                    <option value="  " selected="selected">--请选择--</option>
                                    <option value="stl">结清时间</option>
                                    <option value="back">拖回时间</option>
                                    <option value="form">转正常时间</option>
                                </select>

                                <input name="strDate" id="strDate" type="text" class="ui-datepicker" value="">
                                <span>---</span>
                                <input name="endDate" id="endDate" type="text" class="ui-datepicker" value="">
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">一级支付表状态</div>
                            <div class="field">
                                <select name="firstPrdStsCd" id="firstPrdStsCd" data-value=" ">
                                    <option value=" " seleted >请选择</option>
                                    <c:forEach items="${firstPrdStsCdList }" var="kv">
                                        <option value="${kv.key }">${kv.value }</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="clearFix"></div>
                        <div class="btnsBox">
                            <span id="searchBtn" class="sq-button sq-button-round">查询</span>
                            <span id="clearBtn" onclick="clearBtn();" class="sq-button sq-button-round">清空</span>
                            <sys:funcAuth resCd="stlCstIrr">
                                <input id="isShowStlCstIrr" hidden="hidden" value="1"/>
                            </sys:funcAuth>
                        </div>
                    </div>
                </form>
            </div>
            <div id="grid" class="sq-grid"></div>
        </div>
    </div>
</div>
<div id="changeLsDt" style="display:none">
    <form id="changeLsDt_form">
        <div class="fieldset1 tabel_col tabel_col_s noBorder clearFix">
            <div class="fieldBox col_50">
                <div class="label">起租日</div>
                <div class="field">
                    <input name="lsDtParam" id="lsDtParam" type="text" class="ui-datepicker" validate="{required:true}"
                           value="">
                    <span class="requiredSymbol">*</span>
                </div>
            </div>
        </div>
        <div class="btnsBox">
            <span class="sq-button sq-button-hasicon Hide"><i class="sqBtnIco_10"></i>保存</span>
            <span class="sq-button sq-button-hasicon l-dialog-btn-cancel Hide"><i class="sqBtnIco_14"></i>取消</span>
        </div>
    </form>
</div>
<div id="changePayPd" style="display:none">
    <form id="changePayPd_form">
        <div class="fieldset1 tabel_col tabel_col_s noBorder clearFix">
            <div class="fieldBox col_50">
                <div class="label">期次</div>
                <div class="field">
                    <select name="payPdParam" id="payPdParam" validate="{required:true}">
                    </select>
                    <span class="requiredSymbol">*</span>
                </div>
            </div>
        </div>
        <div class="btnsBox">
            <span class="sq-button sq-button-hasicon Hide"><i class="sqBtnIco_10"></i>保存</span>
            <span class="sq-button sq-button-hasicon l-dialog-btn-cancel Hide"><i class="sqBtnIco_14"></i>取消</span>
        </div>
    </form>
</div>
<div id="setIsLowBiz" style="display:none">
    <div class="fieldset1 tabel_col tabel_col_s noBorder clearFix">
        <div class="fieldBox col_50">
            <div class="label">是否低息</div>
            <div class="field">
                <select name="isLowBiz" id="isLowBiz">
                    <option value="0" selected="selected">否</option>
                    <option value="1">是</option>
                </select>
            </div>
        </div>
    </div>
    <div class="btnsBox">
        <input id="lowBizPrjId" type="hidden" value="">
        <span class="sq-button sq-button-hasicon" onclick="setIsLowBiz()"><i class="sqBtnIco_10"></i>保存</span>
        <span class="sq-button sq-button-hasicon l-dialog-btn-cancel"><i class="sqBtnIco_14"></i>取消</span>
    </div>
</div>
</body>
</html>